<!DOCTYPE html>
<html lang="en">

<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <meta http-equiv="X-UA-Compatible" content="ie=edge">
  <title>Document</title>
</head>

<body>

</body>
<script>
  class Point {
    constructor(x, y) {
      this.x = x;
      this.y = y;
    }
    toString(){
      return '我是父类的方法'
    }
  }
  class ColorPoint extends Point {
    constructor(x, y, color) {
      super(x, y); //  调用父类的 constructor(x, y)
      this.color = color;
    }
    toString() {
      return this.color + ' ' + super.toString(); //  调用父类的 toString()
    }
  }
  let cp = new ColorPoint(25, 8, 'green'); // ReferenceError
  // console.log(cp.toString())


  class Person{
    constructor(name,age){
      this.name=name;
      this.age=age;
    }
    sayHello(){
      console.log(`我的名字是${this.name}，我的年龄是${this.age}`)
    }
  }
  class Student extends Person{
    constructor(name,age,score){
      super(name,age)
      this.score=score;
    }
    study(){
      console.log(this.name+'正在学习，分数是'+this.score)
    }
  }

  let lisi = new Student('战三','34',200)
  lisi.study()
</script>

</html>